package hotgammon.view.tools;

import hotgammon.domain.*;
import hotgammon.view.*;
import java.awt.event.MouseEvent;
import minidraw.standard.*;

/** Board state change tool: tool that on mouse down triggers some
 * event on the board which then hopefully is reflected in the GUI.
 * Note that this particular testing only tool only works at the
 * testing board setup where a single black checker is located on
 * B12.
 */
public class BoardStateChangeTool extends NullTool {
    
    BackgammonUserInterface ui;
    public BoardStateChangeTool(BackgammonUserInterface ui) {
        this.ui = ui;
    }
    
    private class StateChange {
        Location from;
        Location to;
        Color c;
        StateChange(Location l, Location t, Color col) {
            from = l;
            to = t;
            c = col;
        }
    };
    StateChange[] changelist =
    {
        new StateChange(Location.B1, Location.B2, Color.RED),
        new StateChange(Location.B2, Location.B4, Color.RED),
        
        new StateChange(Location.R1, Location.R2, Color.BLACK),
        new StateChange(Location.R2, Location.R4, Color.BLACK),
        
        new StateChange(Location.R6, Location.R3, Color.RED),
        new StateChange(Location.R6, Location.R2, Color.RED),
        
        new StateChange(Location.B6, Location.B2, Color.BLACK),
        new StateChange(Location.B6, Location.B3, Color.BLACK),       
    };
    int index = 0;
    public void mouseDown(MouseEvent arg0, int arg1, int arg2) {
        if (index < changelist.length) {
            StateChange s = changelist[index++];
            ui.getEditor().showStatus("Moving from " + s.from + " to " + s.to);
            ui.getGame().move(s.from, s.to);
        } else {
            ui.getEditor().showStatus("No more moves left in changelist...");
        }
    }
}
